package com.dxy.lc.model.bean;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.ArrayList;
import java.util.List;

@Data
@Accessors(chain = true)
public class TreeVo {

    public static final int NODE_TYPE_DEPT = 1;
    public static final int NODE_TYPE_USER = 2;

    private String id;

    private String text;

    private Object val;

    private String parentId;

    private int sort;

    private boolean hasChildren;

    private List<TreeVo> childList = new ArrayList<>();

    // 节点类型（在通讯录场景中区分部门节点和用户节点）
    private Integer nodeType;

    // 是否可见节点（辅助计算用）
    @JsonIgnore
    @JSONField(serialize = false)
    private boolean visible = true;

    // 添加子节点
    public void addChild(TreeVo treeVo){
        this.hasChildren = true;
        childList.add(treeVo);
    }

}
